//  组合函数  floeRight
const _ = require('lodash')
// const reverse = array => array.reverse()
// const first = array => array[0]
// const compose=_.flowRight(first,reverse)  
// console.log(compose(['333','444']))
// function compose (...args){
//     return function(value){
//         return args.reverse().reduce(function(acc,fn){
//             return fn(acc)
//         },value)
//     }
// }

// const compose = (...args) => value => args.reverse().reduce((acc,fn) => fn(acc),value)
 
// console.log(compose(first,reverse)(['333','444']))

// 函数组合的调试

// NEVER SAY GOODBYE  never-say-goodbye
const log=_.curry((str,v)=>{
    console.log(str,v)
    return v
})
const split = _.curry((sep,str)=>_.split(str,sep))
const join = _.curry((sep,arr) => _.join(arr,sep))
const map = _.curry((fn,arr)=>_.map(arr,fn))
const f = _.flowRight(join('-'),log('2'),map(_.toLower),log('1'),split(' '))
console.log(f('NEVER SAY GOODBYE'))